﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace Basics
{
    class CustomCursor
    {
        public Texture2D Texture { get; set; }
        public Color Tint { get; set; }
        public float Rotation { get; set; }
        public bool Centered { get; set; }
        public Vector2 Offset { get; set; }

        public CustomCursor(Texture2D cursorTexture, Color tint, float rotation, bool centered)
        {
            this.Texture = cursorTexture;
            this.Tint = tint;
            this.Rotation = rotation;
            this.Centered = centered;
            if (centered)
                this.Offset = new Vector2(this.Texture.Width / 2, this.Texture.Height / 2) * -1;
            else
                this.Offset = Vector2.Zero;
        }

        public CustomCursor(Texture2D cursorTexture, Color tint, float rotation, Vector2 offset)
        {
            this.Texture = cursorTexture;
            this.Tint = tint;
            this.Rotation = rotation;
            this.Centered = false;
            this.Offset = offset;
        }

        public void Draw(SpriteBatch spriteBatch, MouseState mouseState, Vector2 offset)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(this.Texture, new Rectangle((mouseState.X + (int)offset.X ) + 2 * ((int)this.Offset.X), (mouseState.Y + (int)offset.Y) + 2 * ((int)this.Offset.Y), this.Texture.Width, this.Texture.Height), new Rectangle(0, 0, this.Texture.Width, this.Texture.Height), this.Tint, this.Rotation, this.Offset, SpriteEffects.None, 0);
            spriteBatch.End();
        }

        public void Draw(SpriteBatch spriteBatch, MouseState mouseState)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(this.Texture, new Rectangle(mouseState.X + 2 * ((int)this.Offset.X), mouseState.Y + 2 * ((int)this.Offset.Y), this.Texture.Width, this.Texture.Height), new Rectangle(0, 0, this.Texture.Width, this.Texture.Height), this.Tint, this.Rotation, this.Offset, SpriteEffects.None, 0);
            spriteBatch.End();
        }
    }
}
